<template>
  <div class="authority">
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-table stripe :data="authList">
        <el-table-column type="index" label="-"></el-table-column>
        <el-table-column prop="authName" label="用户名"></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column prop="level" label="等级">
          <template #default="scope">
            <el-tag v-if="scope.row.level == 0" type="primary">一级</el-tag>
            <el-tag v-else-if="scope.row.level == 1" type="success"
              >二级</el-tag
            >
            <el-tag v-else type="warning">三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "Authority",
  data() {
    return {
      authList: []
    };
  },
  created() {
    this.getAuthList();
  },
  methods: {
    //获取初始数据
    getAuthList() {
      this.$http
        .get("rights/list")
        .then(res => {
          if (res.data.meta.status == 200) {
            console.log(res.data.data);
            this.authList = res.data.data;
          } else {
            return;
          }
        })
        .catch(err => err);
    }
  }
};
</script>

<style lang="scss" scoped></style>
